At 16:58 +0200 on 19/1/99, Valerio Santinelli wrote:
> char(1) won't let me insert into it the values contained in the old
> table seeing they're not of the same type.
Why not? It all depends on how you populate the new table. You do that
usually with a SELECT statement. A select statement like
SELECT field_1, field_2, ( char_field = '1' ), field 4, field5...
gives you a boolean expression - is the char_field equal to '1' at the
current row?
Some versions of Postgres crash when given a boolean expression on the
select target list. In that case you can define it as a function
CREATE FUNCTION is_one( bpchar ) RETURNS bool
AS 'SELECT $1 = ''1'''
LANGUAGUE 'sql';
And then do the select as
SELECT field_1, field_2, is_one( char_field), field4, field5....
Herouth
--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma